package com.talkyun.openx.server.codec;

import com.talkyun.openx.server.core.ServiceFactory;
import com.talkyun.openx.server.core.ServiceRequest;
import com.talkyun.openx.server.helper.UriParser;
import com.talkyun.utils.json.JSON;
import com.talkyun.utils.json.JSONObject;
import com.talkyun.utils.para.ParaNamer;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import static com.talkyun.utils.Reflector.getInterface;
import static com.talkyun.utils.Reflector.getMethod;

public class SecureJsonCodec extends JsonCodec {

    public SecureJsonCodec(ServiceFactory sf) {
        super(sf);
    }

    @Override
    public ServiceRequest decode(String uri, String data) {
        this.validate(uri, data);

        return super.decode(uri, data);
    }

    private void validate(String uri, String data) {
        if (data != null) {
            String tmp = data.toLowerCase();
            if (tmp.contains("\"@type\"") || tmp.contains("\"@\\type\"")) {
                throw new RuntimeException("Not support! " + data);
            }
        }
    }

}